package com.studio701.carguard.controller;


import com.studio701.carguard.pojo.DrivingBehavior;
import com.studio701.carguard.pojo.HumanBody;
import com.studio701.carguard.pojo.RespBean;
import com.studio701.carguard.service.IDrivingBehaviorService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xjc
 * @since 2022-04-15
 */
@RestController
@RequestMapping("/driving-behavior")
public class DrivingBehaviorController {

    @Autowired
    IDrivingBehaviorService iDrivingBehaviorService;

    @ApiOperation("添加驾驶行为信息")
    @PostMapping("/")
    public boolean insertOperation(@RequestBody DrivingBehavior drivingBehavior){
        return iDrivingBehaviorService.save(drivingBehavior);
    }

    @ApiOperation("修改驾驶行为信息")
    @PutMapping("/")
    RespBean updateDrivingBehavior(@RequestBody DrivingBehavior drivingBehavior){
        if(iDrivingBehaviorService.updateById(drivingBehavior)){
            return RespBean.success("更新成功");
        }else{
            return RespBean.error("更新失败");
        }
    }

    @ApiOperation("获取驾驶行为信息")
    @GetMapping("/")
    DrivingBehavior getByUserId(Integer id){
        return iDrivingBehaviorService.getByUserId(id);
    }
}
